import request from '@/utils/request';
import { CORE_JAR_PREFIX } from '@/utils/constants';

export function fetch({ pageNo, pageSize }) {
  return request('/tlss/' + CORE_JAR_PREFIX + '/UserManage',
    { method: 'userData', pageNo, pageSize},
    'POST'
  );
}

export function getAllRoles() {
  return request('/tlss/' + CORE_JAR_PREFIX + '/UserManage',
    { method: 'allRoles'}
  );
}

//{ username, password, phone, email, role }
export function add(user) {
  return request('/tlss/' + CORE_JAR_PREFIX + '/UserManage',
    { method: 'addUser', ...user},
    'POST'
  );
}

//{ username, password, phone, email, role }
export function edit(username, rest) {
  return request('/tlss/' + CORE_JAR_PREFIX + '/UserManage',
    { method: 'editUser', username, ...rest},
    'POST'
  );
}

export function remove(username) {
  return request('/tlss/' + CORE_JAR_PREFIX + '/UserManage',
    { method: 'removeUser', username}
  );
}
